﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>注册 - 华东期货</title>
    <style>
        * {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft JhengHei';
            background: url(img/bg.jpg) no-repeat center top;
            background-size: cover;
            margin: 0;
            padding: 0;
        }

        ul {
            list-style: none;
            margin: 0;
            padding: 0;
            padding: 15px;
        }

        li {
            text-align: center;
            padding-bottom: 15px;
        }

        input {
            border-radius: 6px;
            padding: 10px;
            font-size: 17px;
            line-height: 1em;
            width: 100%;
        }

            input[type=text], input[type=password] {
                border: 1px solid #eee;
            }

            input[type=button] {
                border-width: 0;
                background: #ff6a00;
                color: #fff;
            }

            input::-webkit-input-placeholder {
                color: #ccc;
            }

        .container {
            border-radius: 6px;
            margin: 15px;
            background: #fff;
        }

        .validcode-get {
            position: absolute;
            right: 8px;
            top: 6px;
            font-size: 14px;
            padding: 8px;
        }

        .copyright {
            color: rgba(255,255,255,.5);
            text-align: center;
            position: fixed;
            bottom: 20px;
            width: 100%;
        }

        .banner {
            padding:40px 0 40px;
            color: rgba(255,255,255,.9);
            width: 100%;
            font-size: 30px;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="banner">
        高回报低成本&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
        &nbsp;&nbsp;&nbsp;随时随地操作灵活
    </div>
    <div class="container">
        <ul id="boxReg">
            <li><input id="MobileNo" type="text" placeholder="请输入您的手机号码" /></li>
            <li style="position:relative;"><input id="AuthCode" type="text" placeholder="短信验证码" /><input id="btnSendAuthCode" class="validcode-get" type="button" value="获取验证码" style="width:auto;" /></li>
            <li><input id="Password" type="password" placeholder="登录密码" /></li>
            <li><input id="submit" type="button" value="立刻注册" /></li>
        </ul>
    </div>
    <div class="copyright">© 华东期货</div>

    <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        var $MobileNo = document.getElementById("MobileNo");
        var $Password = document.getElementById("Password");
        var $AuthCode = document.getElementById("AuthCode");

        var isSendAuthCode = false;

        checkMobile = function (mobile) {
            if (mobile == "") {
                alert("请输入手机号");
                return false;
            }

            var reg = /^1[0-9]{10}$/;
            if (!reg.test(mobile)) {
                alert("请输入正确的手机号");
                return false;
            }

            return true;
        }

        $(function () {
            $("#btnSendAuthCode").click(function () {
                if (isSendAuthCode) {
                    return;
                }
                if (!checkMobile($MobileNo.value)) {
                    return;
                }

                var waitTime = 60;
                var waitLoop = setInterval(function () {
                    isSendAuthCode = true;
                    $("#btnSendAuthCode").val(waitTime + " 秒后重发");
                    if (waitTime == 0) {
                        isSendAuthCode = false;
                        clearInterval(waitLoop);
                        $("#btnSendAuthCode").val("获取验证码");
                    }
                    waitTime--;
                }, 1000);

                $.post("/App.ashx?type=GetRegisterAuthCode", { MobileNo: $MobileNo.value }, function (data) {
                    if (data.isSuccess) {
                    } else {
                        alert(data.message);
                        waitTime = 0;
                    }
                }, "json");

            });

            getParam = function (name) {
                var uri = window.location.search.replace('?', '');
                var data = uri.split('&');
                var arr = new Array();
                if (data) {
                    for (var i in data) {
                        var tmp = data[i].split('=');
                        if (tmp[0]) {
                            arr[tmp[0]] = tmp[1];
                        }
                    }
                }
                return arr[name];
            };

            $("#submit").click(function () {
                var mobile = $MobileNo.value;
                var password = $Password.value;
                var authCode = $AuthCode.value;
                var referrerCode = getParam("code");

                if (!checkMobile(mobile)) {
                    return;
                }
                if (password == "") {
                    alert("请输入登录密码");
                    return;
                }
                if (authCode == "") {
                    alert("请输入验证码");
                    return;
                }

                $.post("/App.ashx?type=Register", { Mobile: mobile, Password: password, AuthCode: authCode, ReferrerCode: referrerCode }, function (data) {
                    if (data.isSuccess) {
                        alert("恭喜您，注册成功！下载APP开始交易");
                        window.location = "http://app.chinahdfe.com/";
                    } else {
                        alert(data.message);
                    }
                }, "json");
            });
        });
    </script>
</body>
</html>